<script type="text/javascript">
	function delete_author(id){
		if(confirm("Bạn có chắc chắn xóa?")){
			$.get("/admin/author/delete/"+id).success(function(data){
				location.reload();
			});
		}
	}
	$(document).ready(function(){		
		// $("input[name='key_id']").keyup(function(){
		// 	var id = $("input[name='key_id']").val();
		// 	$.get("/admin/author/search_author?id="+id).success(function(data){
		// 		$("#data-author").html(data);
		// 	});
		// });
		$(".btn-search").click(function(){
			var keyword = $(".text-search").val();
			if($.trim(keyword)==""){
				alert("Ban chua nhap du lieu");
				return false;
			}
		});
	});
</script>
<div class="breadcrumb">
	<ul>
		<li><a href="<?php echo base_url();?>">Home</a></li>
		<li>&rsaquo;</li>
		<li><a href="/admin/author">Quản lý tác giả</a></li>
	</ul>
</div>
<div id="author" class="info-content">
	<h4>Danh sách tác giả</h4>
	<div class="action">
		<a class="add" href="/admin/author/create">Thêm mới</a>
		<span class="search">
			<form action="/admin/author/search_author" method="post">
				<input class="text-search" type="text" name="keyword" value="<?php echo $keyword;?>" placeholder="Nhập tên Tác giả cần tìm..." size="100">
				<input class="btn-search" type="submit" name="" value="Tìm kiếm">
			</form>
		</span>
	</div>	
	<table id="table-author" class="table-data">
		<tr>
			<td class="title col1">STT</td>
			<td class="title col1">ID</td>
			<td class="title">Họ và tên</td>
			<td class="title col2">Ngày sinh</td>
			<td class="title col1">Tác vụ</td>
		</tr>
		<tr>
			<!-- <form>
				<td class="col1"></td>
				<td class="col1">
					<div class="search">
						<input class="text-search" type="text" name="key_id">
						<input class="btn-search" type="submit" name="search_id" value="">
					</div>					
				</td>
				<td>
					<div class="search">
						<input class="text-search" type="text" name="key_name">
						<input class="btn-search" type="submit" name="search_name" value="">
					</div>
				</td>
				<td class="col2">
					<div class="search">
						<input class="text-search" type="text" name="key_ngaysinh">
						<input class="btn-search" type="submit" name="search_ngaysinh" value="">
					</div>
				</td>
				<td class="col1"></td>
			</form> -->
		</tr>
		<?php
		foreach ($author as $key=>$value) {
			echo "<tr>";
				echo "<td class='col1'>".($key+1)."</td>";
				echo "<td class='col1'>".$value['author_id']."</td>";
				echo "<td>".$value["author_name"]."</td>";
				if($value["author_ngaysinh"]==0){
					echo "<td class='col2'></td>";
				}else{
					echo "<td class='col2'>".date("d/m/Y",$value["author_ngaysinh"])."</td>";
				}	
				echo "<td class='col1'>";
					echo "<a class='btn-action edit' href='/admin/author/edit/".$value['author_id']."' title='Sửa'>Sửa</a>";
					echo "<a class='btn-action delete' onclick='delete_author(".$value['author_id'].")' title='Xóa'>Xóa</a>";
				echo "</td>";
			echo "</tr>";
		}
		?>
	</table>
	Hiển thị từ <?php echo $start;?> đến <?php echo $end;?> của <?php echo $total;?> bản ghi <?php echo $link;?>
</div>	
